//
//  UserSectionOneCell.m
//  Arts1
//
//  Created by apple on 15/8/29.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "UserSectionOneCell.h"
#import "AllHeader.h"

@implementation UserSectionOneCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self creactView];
    }
    return self;
}

/**
 *  创建视图控制器
 */
- (void)creactView
{
    _backGroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 20, 200 * HEIGHT)];
    //添加阴影
    [UIView viewShadowColor:_backGroundView];
    _backGroundView.backgroundColor = [UIColor whiteColor];
    _backGroundView.layer.cornerRadius = 5;
    [self.contentView addSubview:_backGroundView];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_backGroundView.left + 5 , _backGroundView.top + 5, 100 * WIDTH, 12)];
    _titleLabel.font = [UIFont systemFontOfSize:12];
    _titleLabel.text = @"我的作品";
    [_backGroundView addSubview:_titleLabel];
    
    _image1 = [[UIImageView alloc] initWithFrame:CGRectMake(2, _backGroundView.bottom - 2 - ((_backGroundView.width - 14) / 6) , (_backGroundView.width - 14) / 6, (_backGroundView.width - 14) / 6)];
    _image1.backgroundColor = kRandomColor;
    _image1.layer.cornerRadius = 3;
    [_image1 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image1.layer.masksToBounds = YES;
    [_backGroundView addSubview:_image1];
    
    _image2 = [[UIImageView alloc] initWithFrame:CGRectMake(_image1.right + 2, _image1.top, _image1.width, _image1.height)];
    _image2.backgroundColor = kRandomColor;
    _image2.layer.cornerRadius = 3;
    [_image2 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image2.layer.masksToBounds = YES;
    [_backGroundView addSubview:_image2];
    
    _image3 = [[UIImageView alloc] initWithFrame:CGRectMake(_image2.right + 2, _image1.top, _image1.width, _image1.height)];
    _image3.backgroundColor = kRandomColor;
    _image3.layer.cornerRadius = 3;
    [_image3 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image3.layer.masksToBounds = YES;
    [_backGroundView addSubview:_image3];
    
    _image4 = [[UIImageView alloc] initWithFrame:CGRectMake(_image3.right + 2, _image1.top, _image1.width, _image1.height)];
    _image4.backgroundColor = kRandomColor;
    _image4.layer.cornerRadius = 3;
    [_image4 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image4.layer.masksToBounds = YES;
    [_backGroundView addSubview:_image4];
    
    _image5 = [[UIImageView alloc] initWithFrame:CGRectMake(_image4.right + 2, _image1.top, _image1.width, _image1.height)];
    _image5.backgroundColor = kRandomColor;
    [_image5 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image5.layer.masksToBounds = YES;
    _image5.layer.cornerRadius = 3;
    
    [_backGroundView addSubview:_image5];
    
    _image6 = [[UIImageView alloc] initWithFrame:CGRectMake(_image5.right + 2, _image1.top, _image1.width, _image1.height)];
    _image6.backgroundColor = kRandomColor;
    _image6.layer.cornerRadius = 3;
    [_image6 setContentMode:(UIViewContentModeScaleAspectFill)];
    _image6.layer.masksToBounds = YES;
    _image6.image = [UIImage imageNamed:@"imagePlus"];
    [_backGroundView addSubview:_image6];
    
    _imageBig = [[UIImageView alloc] initWithFrame:CGRectMake(2, _titleLabel.bottom + 5, _backGroundView.width - 4, _backGroundView.height - _image1.height - _titleLabel.height - 14)];
    _imageBig.backgroundColor = kRandomColor;
    [_imageBig setContentMode:(UIViewContentModeScaleAspectFill)];
    _imageBig.layer.masksToBounds = YES;
    _imageBig.layer.cornerRadius = 2;
    [_backGroundView addSubview:_imageBig];
    
}

- (void)setModel:(MypictureModel *)model
{
    _model = model;
//    [_imageBig sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:(SDWebImageRetryFailed | SDWebImageLowPriority)];
}

- (void)setArray:(NSMutableArray *)array
{
    _array = array;
    
    
    if ( _array.count != 0)
    {
       
        MypictureModel *model1 = _array[0];
        [_imageBig sd_setImageWithURL:[NSURL URLWithString:model1.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        
        
        if (_array.count >= 2) {
            MypictureModel *model2 = _array[1];
            [_image1 sd_setImageWithURL:[NSURL URLWithString:model2.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        }
        
        if (_array.count >= 3) {
            MypictureModel *model3 = _array[2];
            [_image2 sd_setImageWithURL:[NSURL URLWithString:model3.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        }
        
        if (_array.count >= 4) {
            MypictureModel *model4 = _array[3];
            [_image3 sd_setImageWithURL:[NSURL URLWithString:model4.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        }
        
        if (_array.count >= 5) {
            MypictureModel *model5 = _array[4];
            [_image4 sd_setImageWithURL:[NSURL URLWithString:model5.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        }
        
        if (_array.count >= 6) {
            MypictureModel *model6 = _array[5];
            [_image5 sd_setImageWithURL:[NSURL URLWithString:model6.img] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
        }
 
    }
    
}

@end
